.\" Copyright (C) 2006 International Business Machines Corporation
.\" Written by Kent Yoder based on the Trusted Computing Group Software Stack Specification Version 1.1 Golden
.\"
.de Sh \" Subsection
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Ip \" List item
.br
.ie \\n(.$>=3 .ne \\$3
.el .ne 3
.IP "\\$1" \\$2
..
.TH "Tspi_Key_WrapKey" 3 "2004-05-26" "TSS 1.1" "TCG Software Stack Developer's Reference"
.SH NAME
Tspi_Key_WrapKey \- wrap a key with the key addressed by hWrappingKey.
.SH "SYNOPSIS"
.ad l
.hy 0
.nf
.B #include <tss/platform.h>
.B #include <tss/tcpa_defines.h>
.B #include <tss/tcpa_typedef.h>
.B #include <tss/tcpa_struct.h>
.B #include <tss/tss_typedef.h>
.B #include <tss/tss_structs.h>
.B #include <tss/tspi.h>
.sp
.BI "TSS_RESULT Tspi_Key_WrapKey(TSS_HKEY  " hKey ", TSS_HKEY " hWrappingKey ","
.BI "                            TSS_HPCRS " hPcrComposite ");"
.fi
.sp
.ad
.hy
.SH "DESCRIPTION"
.PP
\fBTSS_Key_WrapKey\fR  
wraps the private key \fIhKey\fR using the public key addressed by \fIhWrappingKey\fR. If hPcrComposite is not set to NULL (0), the created key blob is bound to its PCR values. The key object addressed by \fIhKey\fR must contain the key information needed for the creation. On successful return from this call, \fIhKey\fR can be loaded into a TPM. \fIhKey\fR must have been created as a migratable key and should have its usage and migrations secrets set using \fBTspi_Policy_SetSecret(3)\fR.  Also, \fIhKey\fR should have had its private key set to either RSA private component, p or q.
.SH "PARAMETERS"
.PP
.SS hKey
The handle of the key object that is wrapped.
.PP
.SS hWrappingKey
The handle to the key used to wrap the newly created key.
.PP
.SS hPcrComposite
The handle to an object, if the value of the handle doesn't equal NULL, the newly create key will be bound ot the PCR values described with this object.

.SH "RETURN CODES"
.PP
\fBTspi_Key_WrapKey\fR returns TSS_SUCCESS on success, otherwise one of the following values are returned:
.TP
.SM TSS_E_INVALID_HANDLE - Either \fIhKey\fR, \fIhWrappingKey\fR or \fIhPcrComposite\fR are invalid handles.
.TP
.SM TSS_E_INTERNAL_ERROR - An error occurred internal to the TSS.
.SH "CONFORMING TO"

.PP
\fBTspi_Key_WrapKey\fR conforms to the Trusted Computing Group Software Specification version 1.1 Golden
.SH "SEE ALSO"

.PP
\fBTspi_Key_CreateKey\fR(3), \fBTspi_Key_CertifyKey\fR(3), \fBTspi_Key_RegisterKey\fR(3).
